

package cn.shengchao.config;

import cn.shengchao.base.lock.DistributedLock;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.task.AsyncTaskExecutor;
import org.springframework.web.servlet.config.annotation.AsyncSupportConfigurer;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
import org.wildfly.common.Assert;

@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    @Autowired
    private AsyncTaskExecutor asyncTaskExecutor;
    @Autowired
    private DistributedLock distributedLock;

    @Override
    public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
        configurer.setDefaultTimeout(60000); // 设置默认超时时间（毫秒）
        configurer.setTaskExecutor(asyncTaskExecutor); // 设置异步任务执行器
        //断言一下分布式锁是否注入成功
        Assert.assertTrue(distributedLock!=null);
    }

}
